|
|
|
|
|
|
|
Figure 2.10
A chord defined by the Chord API function. |
|
|
|
|
|
|
|
|
operations use the pen. When you are finished using the pen, you should reselect the original pen using SelectObject and then use the DeleteObject function to free the system resources used by the pen you created. If you do not invoke DeleteObject, Windows may eventually run out of resources and none of your programs will be able to get anything done. |
|
|
|
|
|
|
|
|
You use a brush in a similar manner. First you create it using one of the functions CreateBrushIndirect, CreateHatchBrush, CreatePatternBrush, or CreateSolidBrush. Then you make the brush active using SelectObject. When you are finished with the brush, you should reselect the original brush using SelectObject and then use DeleteObject to free the system resources used by the brush you created. |
|
|
|
|
|
|
|
|
Visual Basic's DrawWidth, DrawStyle, FillStyle, and FillColor properties perform almost exactly the same functions as Windows pens and brushes, so you will rarely need to use the API functions directly. It is much simpler to use the Visual Basic properties. |
|
|
|
|
|
|
|
|
One way the pen and brush API functions differ from Visual Basic's properties is in the way a drawing object's background interacts with a filled pattern. When you use only Visual Basic, areas inside a filled area are cleared and replaced by the fill pattern selected by the FillStyle property. The brush API functions allow this behavior too, but they also allow you to keep the background unchanged where the pattern is blank. |
|
|
|
|
|
|
|
|
Figure 2.11
A pie slice drawn by the Pie API function. |
|
|
|
|
|